

package fluebot;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;

/**
 *
 * @author Aksel Kvitberg
 */
public class Log {
	HashMap<String, LogItem> log = new HashMap();
	HashMap<String, LogItem> lastSeen = new HashMap();
	LinkedList<LogItem> lastEvents = new LinkedList<LogItem>();
	private int maxLastEvents = 10;
	String channel;

	public Log(String channel){
		this.channel = channel;
	}

	public void put(LogItem item){
		addToLog(item);
		addToLastSeen(item);
		addToLastEvents(item);
	}

	private void addToLog(LogItem item){
		
	}

	private void addToLastSeen(LogItem item) {
		lastSeen.put(item.login, item);
	}

	private void addToLastEvents(LogItem item) {
		lastEvents.addLast(item);
		if (lastEvents.size() > maxLastEvents)
			lastEvents.removeFirst();
	}

	public ArrayList<String> getLastEvents(){
		Iterator itr = lastEvents.iterator();
		ArrayList<String> returnStr = new ArrayList<String>();
		while(itr.hasNext()){
			LogItem item = (LogItem) itr.next();
			returnStr.add(item.getEventLog());
		}

		return returnStr;
	}

}
